import { useGlobalStore } from "@stores";
import router from "@router";

// 全局前置导航守卫
export const beforeEach = (to: any, from: any, next: any) => {
  const loginState = useGlobalStore().userStore.loginState;
  if (loginState) {
    next();
  } else {
    if (to.fullPath != "/") {
      router.app.config.globalProperties.$showLoginDialog();
      next(false);
    } else {
      next();
    }
  }
};
// 全局后置导航守卫
export const afterEach = () => {
  console.log("后置");
};
